﻿using Microsoft.AspNetCore.HttpOverrides;
using Suntront;
using Suntront.DatabaseAccessor;

namespace AspNetCoreMvcPrj
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }
        public IConfiguration Configuration { get; }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add services to the container.
            services.AddControllersWithViews();
            services.AddSwaggerGen(options =>
            {
                options.CustomOperationIds(type => type.ToString());
            });
           // AppContext.SetSwitch("System.Net.DisableIPv6", true);
            services.AddDatabaseAccessor(options =>
            {

                options.AddDbPool<DMDbContext>($"{DbProvider.Dm}", optionBuilder: opt =>
                {

                },
               //   "Server=32.168.146.8:5236;UserId=XT_ZHSW_BIAOWU;PWD=Zzj123456;SCHEMA=XT_ZHSW_BIAOWU"
                //  "Server=localhost:5236;UserId=XT_ZHSW_BIAOWU;PWD=Zzj123456;SCHEMA=XT_ZHSW_BIAOWU" 

                "Server=32.168.82.8:5236;UserId=XT_ZHSW_BIAOWU;PWD=Xtkj300259;"
                , 10);

            });


        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {

            //  app.UseUnifyResultStatusCodes();
            // Configure the HTTP request pipeline.
            if (!env.IsDevelopment())
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }
            else
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseStaticFiles();
            app.UseHttpsRedirection();
            app.UseRouting();

           // app.UseAuthorization();

                app.UseSwagger();

              app.UseInject(string.Empty);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

        }
    }
}